<!-- eslint-disable no-console -->
<!-- eslint-disable no-console -->
<!--
 * @Description: Description
 * @Author: Kerwin
 * @Date: 2023-07-01 16:22:48
 * @LastEditTime: 2024-03-25 18:05:45
 * @LastEditors:  Please set LastEditors
-->
<template>
    <view class="c_container">
        <u-popup mode="center" v-model="show" :border-radius="'20'">
            <view class="c_main">
                <view class="tit">充值</view>
                <view class="desc">事业部总名额： {{ wallet?.money }}</view>
                <view class="inpt">
                    <u-number-box v-model="count" :min="1" :max="wallet?.money" :input-width="100" :input-height="70"
                        :size="30"></u-number-box>
                </view>
                <u-button type="primary" @click="confirm" :custom-style="{
                    background: '#FF6C18'
                }">充值</u-button>
            </view>
        </u-popup>
    </view>
</template>
  
<script setup lang="ts">
import { ref, reactive, watch } from 'vue';
import { useUserStore } from '@/store'
import { baseApi, moneyApi } from '@/api';
import { dynamic_enum_type } from '@/api/enum';

const emit = defineEmits(['onConfirm'])
const userStore = useUserStore()
const props = withDefaults(
    defineProps<{
        isBack?: boolean
        moneyRuleId?: string | number
    }>(),
    {
        isBack: true,
        moneyRuleId: '',
    }
)
const show = ref(false)
const open = () => {
    show.value = true
}
const count = ref(1)
const wallet = ref({})
const toUserId = ref('')
async function getWalletInfo(companyId, userid) {
    toUserId.value = userid
    uni.showLoading({
        title: '总名额查询中',
    })
    const { data } = await moneyApi.walletInfo({
        objectType: 12,
        objectId: companyId,
        walletRuleId: 1002
    }).finally(() => {
        uni.hideLoading()
    })
    wallet.value = data
}
const confirm = () => {
    emit('onConfirm', {
        count: count.value,
        toUserId: toUserId.value,
        walletId: wallet.value.id
    })
    show.value = false
}
defineExpose({ open, getWalletInfo })
</script>
  
<style lang="scss" scoped>
.c_container {
    .c_main {
        padding: 60rpx 80rpx;

        .tit {
            font-size: 40rpx;
            text-align: center;
            font-weight: bold;
        }

        .desc {
            margin-top: 20rpx;
            margin-bottom: 50rpx;
        }

        .inpt {
            display: flex;
            justify-content: center;
            margin-bottom: 50rpx;
        }
    }

}
</style>
  